Module Architecture
flowchart TD
BASE["sadeem_saas_base\nSAAS Base"]
CON["sadeem.cloudflare.connector\nAccount credentials\nAPI key · Zone ID"]
REC["sadeem.cloudflare.record\nDomain · Type A/CNAME\nProxy · TTL · Zone ref"]
EXT[/Cloudflare API\napi.cloudflare.com/]
BASE --> CON
CON --> REC
CON --> A1([action_confirm\nverify API key → active])
CON --> A2([action_reset_draft\nreset to draft])
CON --> A3([action_cancel\ndeactivate account])
REC --> A4([action_create_cloudflare_record\nPOST dns_records])
REC --> A5([action_update_cloudflare_record\nPUT dns_records / id])
REC --> A6([action_delete_cloudflare_record\nDELETE dns_records / id])
REC --> A7([action_check_status\nGET live state → post chatter])
REC --> A8([duplicate detection\nauto-link on conflict error 81058])
A1 --> EXT
A4 --> EXT
A5 --> EXT
A6 --> EXT
A7 --> EXT
Module Description
Integrates Odoo with the Cloudflare API for DNS management.
| Area |
What it does |
| Cloudflare Accounts |
Store and validate API credentials per Cloudflare account |
| DNS Records |
Create, update, delete A and CNAME records remotely |
| Proxied Mode |
Toggle Cloudflare proxying and configure TTL per record |
| Status Checks |
Compare local record config against live Cloudflare state |
| Duplicate Detection |
Auto-links to existing remote records on conflict (error 81058) |
| Lifecycle |
Draft → Created → Deleted with full chatter tracking |
Dependencies
- mail — chatter, tracking, activity mixin
- sadeem_saas_base — base infrastructure and security groups
SAAS Management
├─ Infrastructure
⎢ └─ Cloudflare
⎢ └─ Accounts
└─ Data
└─ Cloudflare Records
Key Fields
Cloudflare Connector (sadeem.cloudflare.connector)
| Field |
Type |
Description |
| api_key |
Char |
Cloudflare API token (required) |
| state |
Selection |
Account status: draft, confirm, cancel |
| company_id |
Many2one |
Company this connector belongs to |
Cloudflare Record (sadeem.cloudflare.record)
| Field |
Type |
Description |
| cloudflare_connector_id |
Many2one |
The Cloudflare account connector (required) |
| domain |
Char |
Fully qualified domain name to manage (required) |
| record_type |
Selection |
DNS record type: A or CNAME |
| target |
Char |
IP address (A record) or hostname (CNAME) (required) |
| ttl |
Integer |
Time-to-live in seconds (default: 3600) |
| proxied |
Boolean |
Whether Cloudflare proxying is enabled (orange cloud) |
| cloudflare_id |
Char |
Cloudflare's internal DNS record ID (set after creation) |
| cloudflare_zone_id |
Char |
Zone ID from Cloudflare (read-only, set at creation) |
| internal_id |
Char |
Internal reference ID |
| state |
Selection |
Record lifecycle: draft, created |
| created_on_remote |
Boolean |
Whether the record has been successfully created on Cloudflare |
Lifecycle & States
Connector States
| State |
Meaning |
draft |
Credentials not yet verified |
confirm |
API key verified against Cloudflare |
cancel |
Connector deactivated |
Transitions:
- draft → confirm: action_confirm — calls GET /user/tokens/verify on Cloudflare API
- confirm / cancel → draft: action_reset_draft
- Any → cancel: action_cancel
DNS Record States
| State |
Meaning |
draft |
Record defined locally but not yet pushed to Cloudflare |
created |
Record exists on Cloudflare (has a cloudflare_id) |
Transitions:
- draft → created: action_create_cloudflare_record — POSTs to Cloudflare DNS API; on conflict (error 81058) auto-links to existing remote record
- created → draft (effective): action_delete_cloudflare_record — DELETEs from Cloudflare and clears cloudflare_id
Key Actions
| Action |
Model |
Description |
action_confirm |
sadeem.cloudflare.connector |
Verifies API key against api.cloudflare.com/user/tokens/verify; moves to confirm state |
action_reset_draft |
sadeem.cloudflare.connector |
Resets connector to draft state |
action_cancel |
sadeem.cloudflare.connector |
Cancels/deactivates the connector |
action_create_cloudflare_record |
sadeem.cloudflare.record |
POSTs new DNS record to Cloudflare; handles duplicate conflict (error 81058) by auto-linking |
action_update_cloudflare_record |
sadeem.cloudflare.record |
PUTs updated record to Cloudflare using stored cloudflare_id |
action_delete_cloudflare_record |
sadeem.cloudflare.record |
DELETEs the DNS record from Cloudflare and clears the local cloudflare_id |
action_check_status |
sadeem.cloudflare.record |
GETs the live record from Cloudflare and posts a chatter message comparing current vs stored values |
Warnings & Important Notes
- API key required:
api_key is required on the connector; action_confirm will fail if it is missing or invalid.
- Record requires confirmed connector: Creating or updating DNS records via a connector in
draft or cancel state will result in API errors.
- Duplicate record handling: On
action_create_cloudflare_record, if Cloudflare returns error code 81058 (record already exists), the module auto-fetches and links the existing remote record rather than raising an error.
- Connector required for record:
cloudflare_connector_id is required=True on sadeem.cloudflare.record.
- Domain and target required: Both
domain and target are required=True.
- TTL default: TTL defaults to 3600 seconds; setting to
1 means auto-TTL (Cloudflare managed).
- Zone ID is read-only:
cloudflare_zone_id is populated automatically from the connector at record creation and cannot be manually edited.